
function onClickChangeTime(eventObject) {
    $('#dateField').parent().removeClass('has-error has-feedback').find('span').remove();
    var dateField = $('#dateField').val();
    if (!dateField) {
        $('#dateField').parent().addClass('has-error has-feedback');
        $('<span class="help-block"><span class="glyphicon glyphicon-remove"></span> Insert a date!</span>').insertAfter('#dateField');
        return;
    }
    var date = new Date(Date.parse(dateField));
    if (!date) {
        $('#dateField').parent().addClass('has-error has-feedback');
        $('<span class="help-block"><span class="glyphicon glyphicon-remove"></span> Insert a date!</span>').insertAfter('#dateField');
        return;
    }
    setTime(dateField, function() {
        refrehTime();
        $('#dateField').val('');
    });
}

function refrehTime() {
    getTime(function (data) {
        $('#currentTime').text(data["day"] + '/' + (data["month"] + 1) + '/' + data["year"] + '  ' + data["hour"] + ':' + data["minutes"] + ':' + data["seconds"]);
    });
}

$(document).ready(function () {
    refrehTime();
    $('#dateField').datetimepicker({
        closeOnDateSelect:true,
        step: 5,
        startDate: '+1970/01/02',
        defaultDate: '+1970/01/02',
        defaultTime: '09:00'
    });
});
